<?php

/* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $model \common\models\LoginForm */

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use frontend\models\FenhuiForm;

$this->title = '申请分会';
$this->params['breadcrumbs'][] = $this->title;
?>
<style>
	.bo{background: #FFF;}
</style>
			<section class="formbox">
				<form  action="<?= yii\helpers\Url::to(['member/apply_association']);?>" enctype="multipart/form-data" id="subform" method='post'>
					<input name="_csrf" type="hidden" id="_csrf" value="<?= Yii::$app->request->csrfToken ?>">
	            <div class="textlines">
	            	<ul>
	            		<li><span class="boxtt">统一社会信用代码：</span><input style="width: 3.2rem;" type="text"  value="<?= $member['yyzhizao'] ?>" id="yyzhizao" name="yyzhizao"  placeholder="请输入统一社会信用代码"/><span class="xing">*</span></li>
	            		<li><span class="boxtt">营业执照所在地：</span>
							<input style="width: 3.2rem;" type="text" id="zcdizhi" name="zcdizhi" value="<?= $member['zcdizhi'] ?>"  placeholder="营业执照所在地"/>
	            			<span class="xing">*</span></li>
	            		<li>
	            			<span class="boxtt">营业执照有效期：</span>
	            			<input id="Text1" style="width:1.5rem; height: 0.5rem; margin-top: 0.15rem;font-size: 0.24rem; text-align: center;" name="qychengli" value="<?= $member['qychengli'] ?>" onClick="calendar.show({ id: this })" type="text" placeholder="-请选择-" />
	            			<span style="font-size: 0.26rem; color: #444; float: left; margin: 0.2rem 0.1rem;">至</span>
	            			<input style="width:1.5rem; height: 0.5rem; margin-top: 0.15rem;font-size: 0.24rem;text-align: center;" id="Text2" name="qychenglizhi" value="<?= $member['qychenglizhi'] ?>" type="text" placeholder="-请选择-" />
	            			<span class="xing">*</span>
	            		</li>
	            		<li>
	            			<span class="boxtt">法定经营范围：</span>
	            			<textarea style="width: 3.8rem; min-height: 2rem; float: left; margin-top: 0.15rem;padding-top: 0.15rem; border: none;" id="jyfanwei" name="jyfanwei" ><?= $member['jyfanwei'] ?></textarea>
	            		</li>
	            		<li>
	            			<div class="boxline2" style="border: none;">
			                	<span>营业执照电子版：</span>
			                	
			                    <div class="midinput">
			                        <span class="btn upload">-请添加-<input type="file" class="upload_pic" id="upload" name="yyzhizhaoimg" value="<?= $member->yyzhizhaoimg ?>" /></span>
			                    </div>
			                    <span class="xing">*</span>
								<?php
								if(!empty($cardf['newname']))
								{?>
									<img class="s_img" name="cardf" src="<?=Yii::$app->params['setshow']?><?= json_decode($member['yyzhizhaoimg'], true)['newname'];?>" />
								<?php } ?>
			                    <canvas class="all_cva" id="cvs"></canvas>
			                </div>
	            		</li>
	            	</ul>
	            </div>
					<input type="hidden" name="status"  value="10" />
					<input type="hidden" name="step"  value="2" />
	            <div class="buzhou"><a href="" class="upbtn">上一步</a><button id="sub" class="nextbtn" type="button">下一步</button></div>

				</form>


			</section>
			
<script type="text/javascript">
$(document).ready(function() {
  $("#sub").click(function(){
       var yyzhizao = $("#yyzhizao").val();
       var zcdizhi = $("#zcdizhi").val();
       var jyfanwei = $("#jyfanwei").val();
       if(yyzhizao==""){
          alert("请填写统一社会信用代码！");
        return false;
         }
         
       if(zcdizhi==""){
          alert("请填写营业执照所在地！");
        return false;
         }

       if(jyfanwei==""){
          alert("请填写法定经营范围！");
        return false;
         }
        $("#subform").submit();
    })
    
}) ;
</script>
<script type="text/javascript">
$("#Text2").click(function (e) {
	var ths = this;
	calendar.show({
		id: this, ok: function () {
			//alert(ths.value);
		}
	});
});
</script>            
<script>
//获取上传按钮
var input1 = document.getElementById("upload"); 
 
if(typeof FileReader==='undefined'){ 
     //result.innerHTML = "抱歉，你的浏览器不支持 FileReader"; 
     input1.setAttribute('disabled','disabled'); 
}else{ 
     input1.addEventListener('change',readFile,false); 
     /*input1.addEventListener('change',function (e){
     	console.log(this.files);//上传的文件列表
     },false); */
}
function readFile(){ 
	var file = this.files[0];//获取上传文件列表中第一个文件
	if(!/image\/\w+/.test(file.type)){
	//图片文件的type值为image/png或image/jpg
		alert("文件必须为图片！");
		return false; 
	} 
	// console.log(file);
	var reader = new FileReader();//实例一个文件对象
	reader.readAsDataURL(file);//把上传的文件转换成url
	//当文件读取成功便可以调取上传的接口
	reader.onload = function(e){ 
		// console.log(this.result);//文件路径
		// console.log(e.target.result);//文件路径
		/*var data = e.target.result.split(',');
		var tp = (file.type == 'image/png')? 'png': 'jpg';
		var imgUrl = data[1];//图片的url，去掉(data:image/png;base64,)
		//需要上传到服务器的在这里可以进行ajax请求
		// console.log(imgUrl);
		// 创建一个 Image 对象 
		var image = new Image();
		// 创建一个 Image 对象 
		// image.src = imgUrl;
		image.src = e.target.result;
		image.onload = function(){
			document.body.appendChild(image);
		}*/

		var image = new Image();
		// 设置src属性 
		image.src = e.target.result;
		var max=200;
		// 绑定load事件处理器，加载完成后执行，避免同步问题
		image.onload = function(){ 
			// 获取 canvas DOM 对象 
			var canvas = document.getElementById("cvs"); 
			// 如果高度超标 宽度等比例缩放 *= 
			/*if(image.height > max) {
				image.width *= max / image.height; 
				image.height = max;
			} */
			// 获取 canvas的 2d 环境对象, 
			var ctx = canvas.getContext("2d"); 
			// canvas清屏 
			ctx.clearRect(0, 0, canvas.width, canvas.height); 
			// 重置canvas宽高
			/*canvas.width = image.width;
			canvas.height = image.height;
			if (canvas.width>max) {canvas.width = max;}*/
			// 将图像绘制到canvas上
			// ctx.drawImage(image, 0, 0, image.width, image.height);
			ctx.drawImage(image, 0, 0, 250, 150);
			// 注意，此时image没有加入到dom之中
		};  
	}
};
</script>


